import Vue from 'vue'
import * as apis from '../../services/apis'
import * as types from '../mutation-types'
import http from '../../http'

const state = {
  car_pro_list: {}
}

const getters = {
  car_pro_list: state => state.car_pro_list
}

const actions = {
  getCartProList({
    commit
  }, payload) {
    let accessToken = JSON.parse(localStorage.getItem('token')).accessToken
    Vue.http.post(apis.GET_CART_PRO, {
      accessToken: accessToken
    }).then((res) => {
      commit(types.GET_CART_PRO, res.body)
    })
  }
}

const mutations = {
  [types.GET_CART_PRO](state, payload) {
    state.car_pro_list = payload.result
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
